<?php require_once 'header.php';
require_once 'backend/Employees.php';

if(isset($_SESSION['employee']))
{
	$employee = unserialize($_SESSION['employee']);
}
?>

	<div id = "pagecontent">
	<h1>EMPLOYEE</h1>
	<fieldset>
	  <legend>Orders</legend>
	  <form method='post'>
	  <?php 
	  	$eid = $employee->getEid();
	 	$html = "<select name = Order>";
		$result = $employee->getEmpJobs($eid);
		echo "<br>";
	  	while($row = mysql_fetch_array($result))
	  	{
	  		$orderNo = $row['order_no'];
	  		$html .= '<option value='.$orderNo.'>'.'Order # '.$orderNo.'</option>';
	  	}
	  	$html .= "</select>";
	  	echo $html;
	  	if (isset($_POST['OrderComplete']))
	  	{ 
	  		$completeOrder = $_POST['Order'];
	  		echo "<p>Removing Order #".$completeOrder.".....</p>";
	  		$employee->completeOrder($completeOrder);
	  		?>
			<script language="JavaScript">window.location.href="Jobs.php"</script>
	  <?php 
	  	}
	  	else if (isset($_POST['ViewOrder']))
	  	{ 
	  		if(isset($_POST['Order']))
	  		{
	  			$viewOrder = $_POST['Order'];
	  			echo "<p>Order #".$viewOrder.":</p>";
	  			$employee->viewOrder($viewOrder);
	  		}
	  		else 
	  			echo "<p>No Order Selected</p>";
	  		
	  	} 
	  ?>
	  <br><br>
	  <input type="submit" value="Finish" name="OrderComplete">
	  <input type="submit" value="ViewOrder" name="ViewOrder">
	  <input type="reset" value="Clear" name = "Clear" onclick="window.location.href='Jobs.php'">
	  </form>
	  </fieldset>
	</div>
	
<?php require_once 'footer.php';?>